/*
 * Copyright (C) 2011 Project R'yleh Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.Arkham;

import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;

public class NewGame01 extends Activity  implements OnClickListener{
	
	TextView speaking, text1, text2;
	EditText text3, character_name, worst_fear;
	int state = 0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		//removes title bar and sets the theme
        this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        
		super.onCreate(savedInstanceState);
		setContentView(R.layout.newgame01);
		
		//set up the new game information in party
		GameFile.party.NewGame();
		for(int i=0; i<GameFile.numStoryFlags; i++)
			GameFile.storyFlag[i] = false;
		
		//give starting character a sprite
		Actor Sprite = new Actor(1,1, BitmapFactory.decodeResource(getResources(), com.Arkham.R.drawable.hero), 64,64);
		GameFile.party.characters[0].setActor(Sprite);
		
		View newGameInfoButton = findViewById(com.Arkham.R.id.newGameCollection_button);
		newGameInfoButton.setOnClickListener(this);
        
		speaking = (TextView) findViewById(R.id.ng1_speaking);
		text1 = (TextView) findViewById(R.id.newgameText);
		text2 = (TextView) findViewById(R.id.collectedInfo_Title);        
        text3 = (EditText) findViewById(R.id.collected_information);
        
        speaking.setText( "Head Master: ");
        text1.setText( Dialogue.newGame01() );
		text2.setText("Name:");
        text3.setText("");
        
	}
	public void onClick(View v) {
    	Intent i;
    	switch (state)
    	{
    	case 0:
    		String name = text3.getText().toString();
    		if(name == "")
    			break;
    		GameFile.party.characters[0].changeName(name);
    		text1.setText( Dialogue.newGame02() );
    		text2.setText("Worst Fear:");
    		text3.setText("");
    		state++;
    		break;
    	default:
   		    String fear = text3.getText().toString();
    		if(fear == "")
    			break;
    		GameFile.party.characters[0].changeWorstFear(fear);
    		i = new Intent(this, NewGame02.class);
	    	startActivity(i);
	    	//added to get to main menu
	    	finish();
	    	break;
    	}
	}
}


